package com.zyc.app.woa.activity;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
import com.zyc.app.woa.R;
import com.zyc.app.woa.utils.CommonUtils;

/**
 * Created by zyc on 12/27/14.
 */
public class
        AboutActivity extends BaseActivity {
    private TextView mRateUs;
    private TextView mVersionInfo;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_about_layout);
        mRateUs = (TextView) findViewById(R.id.rate_us);
        mVersionInfo = (TextView) findViewById(R.id.version_info);

        getActionBar().setTitle(R.string.about);
        mVersionInfo.setText(getString(R.string.version_x, getString(R.string.app_name), CommonUtils.getAppVersion()));
        mRateUs.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                gotoMarket(v.getContext());
            }
        });
    }

    protected void gotoMarket(Context context) {
        String packageName = context.getPackageName();
        try {
            context.startActivity(
                    new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + packageName)));
        } catch (android.content.ActivityNotFoundException anfe) {
            context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + packageName)));
        }
    }

}
